<template>
  <el-form style="width: 250px" label-width="80px" size="mini">
    <el-form-item label="昵称">
      <el-input v-model.trim="user.name" size="small"/>
    </el-form-item>
    <el-form-item label="手机">
      <el-input v-model.trim="user.mobile" size="small"/>
    </el-form-item>
    <el-form-item label="公司名称">
      <el-input v-model.trim="user.title" size="small"/>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submit">更新</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import {updateUser} from "@/api/user";

export default {
  props: {
    user: {
      type: Object,
      default: () => {
        return {
          nickname: '',
          mobile: '',
          title: '',
          status:1
        }
      }
    }
  },
  methods: {
    submit() {
      updateUser(this.user).then(res => {
        if(res.code == 20000){
          this.$message.success('资料已修改,请重新登录')
        }else{
          this.$message.error(res.message)
        }
      })
    }
  }
}
</script>
